package com.sth.staservice.controller;


import com.sth.commonutils.R;
import com.sth.staservice.service.StatisticsDailyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 * 网站统计日数据 前端控制器
 * </p>
 *
 * @author sth
 * @since 2020-12-26
 */
@RestController
@CrossOrigin
@RequestMapping("/staservice/sta")
public class StatisticsDailyController {
    @Autowired
    private StatisticsDailyService staSerivce;

    // 统计某一天的注册人数
    @PostMapping("registerCount/{day}")
    public R registerCount(@PathVariable String day) {
        staSerivce.registerCount(day);
        return R.ok();
    }

    // 图表显示 .返回两部分的数据 ,日期json,数量json 数组
    @GetMapping("showData/{type}/{begin}/{end}")
    public R showData(@PathVariable String type, @PathVariable String begin, @PathVariable String end) {
        Map<String, Object> map = staSerivce.getShowData(type,begin,end);
        return R.ok().data(map);
    }
}

